package edu.jhu.secondhome.database.beans;

import java.util.Date;

/**
 * Database Bean: Reservation
 */
public class Reservation {
	
	// This is auto-incremented by DB - but the value will be present when pulled
	private int reservationId;
	private String email;
	private String hotelName;
	private String roomNumber;
	private Date startDate;
	private int numOfDays;
	private int numOfPeople;
	private int totalCost;
	
	public Reservation() { }

	public Reservation(int reservationId, String email, String hotelName,
			String roomNumber, Date startDate, int numOfDays, int numOfPeople, 
			int totalCost) {
		this.reservationId = reservationId;
		this.email = email;
		this.hotelName = hotelName;
		this.roomNumber = roomNumber;
		this.startDate = startDate;
		this.numOfDays = numOfDays;
		this.numOfPeople = numOfPeople;
		this.totalCost = totalCost;
	}

	public int getReservationId() {
		return reservationId;
	}

	public void setReservationId(int reservationId) {
		this.reservationId = reservationId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getHotelName() {
		return hotelName;
	}

	public void setHotelName(String hotelName) {
		this.hotelName = hotelName;
	}

	public String getRoomNumber() {
		return roomNumber;
	}

	public void setRoomNumber(String roomNumber) {
		this.roomNumber = roomNumber;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public int getNumOfDays() {
		return numOfDays;
	}

	public void setNumOfDays(int numOfDays) {
		this.numOfDays = numOfDays;
	}

	public int getNumOfPeople() {
		return numOfPeople;
	}

	public void setNumOfPeople(int numOfPeople) {
		this.numOfPeople = numOfPeople;
	}

	public int getTotalCost() {
		return totalCost;
	}
	
	public void setTotalCost(int totalCost) {
		this.totalCost = totalCost;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((hotelName == null) ? 0 : hotelName.hashCode());
		result = prime * result + numOfDays;
		result = prime * result + numOfPeople;
		result = prime * result + reservationId;
		result = prime * result
				+ ((roomNumber == null) ? 0 : roomNumber.hashCode());
		result = prime * result
				+ ((startDate == null) ? 0 : startDate.hashCode());
		result = prime * result + totalCost;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Reservation other = (Reservation) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (hotelName == null) {
			if (other.hotelName != null)
				return false;
		} else if (!hotelName.equals(other.hotelName))
			return false;
		if (numOfDays != other.numOfDays)
			return false;
		if (numOfPeople != other.numOfPeople)
			return false;
		if (reservationId != other.reservationId)
			return false;
		if (roomNumber == null) {
			if (other.roomNumber != null)
				return false;
		} else if (!roomNumber.equals(other.roomNumber))
			return false;
		if (startDate == null) {
			if (other.startDate != null)
				return false;
		} else if (!startDate.equals(other.startDate))
			return false;
		if (totalCost != other.totalCost)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Reservation [reservationId=" + reservationId + ", email="
				+ email + ", hotelName=" + hotelName + ", roomNumber="
				+ roomNumber + ", startDate=" + startDate + ", numOfDays="
				+ numOfDays + ", numOfPeople=" + numOfPeople + ", totalCost="
				+ totalCost + "]";
	}
}
